package com.hand.demo.api.controller.v1;

import org.hzero.core.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.choerodon.core.iam.ResourceLevel;
import io.choerodon.swagger.annotation.Permission;
import io.swagger.annotations.ApiOperation;
import java.util.Map;
import org.hzero.boot.platform.code.builder.CodeRuleBuilder;

@RestController("CodeRuleController.v1")
@RequestMapping("/v1/code-rule-demo")
public class CodeRuleController extends BaseController {
    @Autowired
    private CodeRuleBuilder codeRuleBuilder;

    @ApiOperation(value = "生成租户级编码规则（按照租户隔离）")
    @Permission(level = ResourceLevel.SITE, permissionLogin = true)
    @PostMapping("/code-rule")
    public String generateCode(Long tenantId, String ruleCode, String levelCode, String levelValue, Map<String, String> variableMap) {
        return codeRuleBuilder.generateCode(tenantId, ruleCode, levelCode, levelValue, variableMap);
    }
}
